package exe.ch3;

import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class Test {
    public static void main(String[] args) {
        Market ma = new Market();
        ma.marketName = "合家福";
        ma.marketAdress = "1号路1号";
        int choise = 0;
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请选择功能：1：添加新会员，2：涨分，3：兑换礼品，4：查看会员，0：退出");
            choise = sc.nextInt();
            switch (choise) {
                case 1:
                    System.out.println("请输入会员号：");
                    String cardNum = sc.next();
                    System.out.println("请输入姓名：");
                    String name = sc.next();
                    System.out.println("请输入手机号：");
                    String phoneNum = sc.next();
                    Memberc mem = new Memberc(cardNum, name, phoneNum, 0);
                    boolean ok = ma.add(mem);
                    System.out.println(ok ? "添加成功!" : "添加失败!");
                    break;
                case 2:
                    System.out.println("请输入会员号：");
                    cardNum = sc.next();
                    System.out.println("请输入此次加分：");
                    int integral = sc.nextInt();
                    ok = ma.inc(cardNum, integral);
                    System.out.println(ok ? "加分成功!" : "帐号不存在!");
                    break;
                case 3:
                    System.out.println("请输入会员号：");
                    cardNum = sc.next();
                    System.out.println("请选择礼品类型(1-3)：");
                    int lipinchoise = 0;
                    while ((lipinchoise = sc.nextInt()) < 0 || lipinchoise > 3) {
                        System.out.println("输入错误，请重新选择（1-3）：");
                    }
                    String result = ma.duihuan(cardNum, lipinchoise);
                    System.out.println(result);
                    break;
                case 4:
                    ma.show();
                    break;
                case 0:
                    System.out.println("退出！");
                    return;
                default:
                    System.out.println("输入错误！");
                    break;
            }
        }
    }
}